package org.lanqiao.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.lanqiao.entity.Admin;
import org.lanqiao.mapper.AdminMapper;
import org.lanqiao.service.AdminService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/login")
public class LoginController {
	@Resource
	private AdminService adminService;
	
	@RequestMapping("/showLogin.do")
	public ModelAndView showLogin() {
		return new ModelAndView("login2");
	}
	@RequestMapping("/login.do") 
	public String login(Admin admin1,HttpSession session) {
		Admin admin=adminService.Login(admin1);
		if(admin!=null) {
			session.setAttribute("admin", admin);
			return "index";
		}
		else {
			return "login2";
		}
		//System.out.println(admin);
	}
	@RequestMapping("index.do")
	public String showIndex(HttpSession session) {
		Admin admin = (Admin)session.getAttribute("admin");
		if(admin==null) {
			return "login2";
		}
		return "index";
	}
	@RequestMapping("showReport.do")
	public String showReport(HttpSession session) {
		
		return "report/report_list";
	}
	@RequestMapping("showUserInfo.do")
	public String showUserInfo(HttpSession session) {
		
		return "user/user_info";
	}
	@RequestMapping("showUserModiPwd.do")
	public String showUserModiPwd(HttpSession session) {
		
		return "user/user_modi_pwd";
	}
}
